import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		token: uni.getStorageSync('scan-token') ? uni.getStorageSync('scan-token') : '',
		userInfo: uni.getStorageSync('scan-userinfo') ? JSON.parse(uni.getStorageSync('scan-userinfo')) : {},
		place: {},
		userId: uni.getStorageSync('scan-userId') ? uni.getStorageSync('scan-userId') : '',
		shopData: uni.getStorageSync('scancode') ? JSON.parse(uni.getStorageSync('scancode')) : [],
	},
	mutations: {
		SET_TOKEN(state, token) {
			state.token = token
		},
		SET_USERID(state, userId) {
			state.userId = userId
		},
		SET_USERINFO(state, userInfo) {
			state.userInfo = userInfo
		},
		SET_PLACE(state, place) {
			state.place = place
		},
		SET_SHOP(state, shopData){
			state.shopData = shopData
		}
	}
})
export default store
